#!/bin/bash

# 获取第一个参数作为目标 IP
TARGET_IP="$1"

# 判断是否传入 IP 地址
if [ -z "$TARGET_IP" ]; then
    echo "Usage: $0 <target_ip>"
    echo ""
    echo "using default ip address 192.168.123.18"
    TARGET_IP="192.168.123.18"
fi

# 执行 rsync 同步操作
sshpass -p "123" rsync -a --progress ./ unitree@"$TARGET_IP":/home/unitree/aiit/go2/rtmp

# 检查是否成功
if [ $? -eq 0 ]; then
    echo "go2 police code update successful!"
else
    echo "update failed!"
    exit 1
fi
